#ifndef __GoalPipeXMLReader_H__
#define __GoalPipeXMLReader_H__

#include <IGoalPipe.h>

class CGoalPipeXMLReader
{
public:
	CGoalPipeXMLReader(const char* szFileName);
	
	bool Success() { return m_bSuccess; }
	
private:
	void ParseGoalPipes(XmlNodeRef& root);
	void ParseGoalOps(IGoalPipe* pGoalPipe, XmlNodeRef& root,
		string sIfLabel = string(), bool b_IfElseEnd_Halves_ReverseOrder = true);
	void ParseGoalOp(IGoalPipe* pGoalPipe, XmlNodeRef& goalOpNode);

	string GenerateUniqueLabelName();

private:
	class CXMLAttrReader
	{
		typedef std::pair<const char*, int> TRecord;
		std::vector<TRecord> m_dictionary;

	public:
		void Add(const char* szKey, int nValue) { m_dictionary.push_back(TRecord(szKey, nValue)); }
		bool Get(const char* szKey, int& nValue);
	};

	CXMLAttrReader m_dictBranchType;

	IGoalPipe::EGroupType m_currentGrouping;

	string m_currentContinueLabel;
	string m_currentBreakLabel;

	uint32 m_nextUniqueLabelID;

	bool m_bSuccess;
};


#endif	// #ifndef __GoalPipeXMLReader_H__
